<template>
  <div style="padding: 0.3rem;">
    <div style="margin-bottom: 0.2rem;"><van-field v-model="shoukuanzhanghu.name" placeholder="请输入支付宝账号姓名" /></div>
    <div style="margin-bottom: 0.2rem;"><van-field v-model="shoukuanzhanghu.account" placeholder="请输入支付宝账号" /></div>
    <van-button type="primary" size="normal" @click="getlist()" text="保存"></van-button>
  </div>
</template>

<script>
  export default {
    name: 'index',
    data() {
      return {
        shoukuanzhanghu:{
        	name:"",
        	account:""
        }
      }
    },
    created() {
      this.getlist2()
    },
    methods: {
      getlist2: function() {
        axios.get(`${this.IP_URL}/api/pay/accountget`).then(response=> {
        		if (response.data.msg.code == 0) {
              if(response.data.data){
                this.shoukuanzhanghu = response.data.data
              }else{
                this.shoukuanzhanghu = {
                	name:"",
                	account:""
                }
              }
        		} else {
        			vant.Toast(response.data.msg.info);
        		}
        	})
      },
      getlist: function() {
        axios.post(`${this.IP_URL}/api/pay/accountset`,{
          name: this.shoukuanzhanghu.name,
          account: this.shoukuanzhanghu.account
        }).then(response=> {
        		if (response.data.msg.code == 0) {
              vant.Toast('修改成功');
              this.$router.back(-1)
        		} else {
        			vant.Toast(response.data.msg.info);
        		}
        	})
      }
    }
  }
</script>


<style scoped lang="less">


</style>
